<!--
 * @Author: your name
 * @Date: 2022-04-07 17:46:41
 * @LastEditTime: 2022-04-07 17:54:58
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\面试题例题220407.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>面试题</title>
</head>

<body>
  <script>
    //谁调用就指向谁
    var name = 'window'
    const obj = {
      name: 'obj',
      sayName: function () {
        console.log(this.name)
      },
    }
    obj.sayMyName = () => {
      console.log(this.name)
    }
    const fn1 = obj.sayName()
    const fn2 = obj.sayMyName()
    fn1 // obj
    obj.sayName() // window
    fn2 // obj
    obj.sayMyName() // window
  </script>
</body>

</html>